package com.opencee.common.converter;

import cn.hutool.core.date.DateUtil;
import org.springframework.core.convert.converter.Converter;
import org.springframework.expression.ParseException;

import java.util.Date;

/**
 * 自定义日期转换器
 *
 * @author yadu
 */
public class DateConverter implements Converter<String, Date> {

    @Override
    public Date convert(String s) {
        if ("".equals(s) || s == null) {
            return null;
        }
        try {
            return DateUtil.parse(s);
        } catch (ParseException e) {
            e.printStackTrace();
        }
        return null;
    }
}
